package com.xx.pmis.services.implementations;

import java.util.List;

import com.xx.pmis.model.Diary;
import com.xx.pmis.persistence.dao.DiaryDAO;
import com.xx.pmis.services.DiaryService;

public class DiaryServiceImpl implements DiaryService {
	DiaryDAO diaryDAO = null;

	public DiaryServiceImpl(DiaryDAO diaryDAO) {
		super();
		this.diaryDAO = diaryDAO;
	}

	public void saveOrUpdateDiary(Diary diary) throws Exception {
		diaryDAO.saveOrUpdate(diary);
	}

	public void saveDiary(Diary diary) throws Exception {
		diaryDAO.save(diary);
	}

	public void deleteDiary(Diary diary) throws Exception {
		diaryDAO.delete(diary);
	}

	public Diary getDiaryByDiaryID(String diaryID) throws Exception {
		Diary diary = diaryDAO.getDiaryByDiaryID(diaryID);
		return diary;
	}

	public List<Diary> getAllDiary() throws Exception {
		List<Diary> diarys = diaryDAO.getAllDiary();
		return diarys;
	}

	public List<Diary> getAllDiaryByPage(int currentPage, int lineSize) throws Exception {
		List<Diary> diarys = diaryDAO.getAllDiaryByPage(currentPage, lineSize);
		return diarys;
	}

	public int getCountOfDiary() throws Exception {
		return diaryDAO.getAllDiary().size();
	}

}
